package com.lizi.idgenerator.controller;

import com.lizi.idgenerator.dto.idcreator.IdCreatorAddModel;
import com.lizi.idgenerator.dto.ResultModel;
import com.lizi.idgenerator.service.impl.IdCreatorServiceImpl;
import com.lizi.idgenerator.utils.ModelValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author kingman
 * @since 2020-12-16 13:47
 */
@Controller
@RequestMapping("creator")
public class CreatorController {

    @Autowired
    private IdCreatorServiceImpl idCreatorService;

    @RequestMapping("add")
    @ResponseBody
    public ResultModel<Boolean> crete(@RequestBody IdCreatorAddModel idCreatorAddModel)
    {
        ModelValidator.validate(idCreatorAddModel);
        ResultModel<Boolean> resultModel = idCreatorService.add(idCreatorAddModel);
        return resultModel;
    }

}
